#备份bili.txt
file = open("D:/me/study/python/execise/基础语法2/一、文件/bill.txt",'r',encoding="UTF-8")
bak = file.read() #读取bili.txt
file.close()
file = open("D:/me/study/python/execise/基础语法2/一、文件/bill.txt.bak",'w',encoding="UTF-8")
file.write(f"{bak}") #将bili.txt写入到bili.txt.bak
file.close()

#打开bili.txt.
#创建一个用来存储的文件
file_old = open("D:/me/study/python/execise/基础语法2/一、文件/bill.txt",'r',encoding="UTF-8")
file_new = open("D:/me/study/python/execise/基础语法2/一、文件/bill_new.txt",'w',encoding="UTF-8")

file_line_old = file_old.readlines()
file_line_new = ""
for x in file_line_old:
    if x.count("测试")==0:
        file_line_new+=x

file_new.write(f"{file_line_new}")

file_old.close()
file_new.close()
